package GUI;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import Run_System.Equation;
import Run_System.Exercises;
import Run_System.ExervisesFactory;

public class Generation_Exercises_Panel extends JPanel {
    private static final int DEFAULT_WIDTH = 800;
    private static final int DEFAULT_HEIGHT = 600;
    //习题册

    public Generation_Exercises_Panel(){
       setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);
       setLayout(new BorderLayout());

       Font font = new Font("微软雅黑",Font.PLAIN,14);

        JPanel jPanel = new JPanel();
        jPanel.setLayout(null);
        jPanel.setFont(new Font("微软雅黑",Font.PLAIN,14));
        jPanel.setVisible(true);
        add(jPanel,BorderLayout.CENTER);

        JButton addButton = new JButton("加法模式");    //点击按钮，会跳转到InputPanel，定义习题的数量和算式范围
        addButton.setBounds(350,50,100,50);
        addButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                InputPanel panel = new InputPanel(1);
                removeAll();
                add(panel);
                validate();
            }
        });
        jPanel.add(addButton);

        JButton subButton = new JButton("减法模式");
        subButton.setBounds(350,150,100,50);
        subButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                InputPanel panel = new InputPanel(2);
                removeAll();
                add(panel);
                validate();
            }
        });
        jPanel.add(subButton);


        JButton mulButton = new JButton("乘法模式");
        mulButton.setBounds(350,250,100,50);
        mulButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        jPanel.add(mulButton);

        JButton divButton = new JButton("除法模式");
        divButton.setBounds(350,350,100,50);
        divButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

            }
        });
        jPanel.add(divButton);

        JButton customButton = new JButton("自定义");
        customButton.setBounds(350,450,100,50);
        customButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                CustomPanel panel = new CustomPanel();
                removeAll();
                add(panel);
                validate();
            }
        });
        jPanel.add(customButton);


        JLabel label_south = new JLabel("书山有路勤为径，学海无涯苦作舟");
        label_south.setFont(new Font("微软雅黑",Font.PLAIN,12));
        label_south.setVisible(true);
        label_south.setHorizontalAlignment(SwingConstants.CENTER);
        label_south.setVerticalAlignment(SwingConstants.BOTTOM);
        add(label_south,BorderLayout.SOUTH);
    }


    public static void main(String[] args) {
        JFrame frame = new JFrame();
        frame.setSize(852,600);
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setLocationRelativeTo(null);
        frame.add(new Generation_Exercises_Panel());
        frame.setVisible(true);
    }
}

